package com.bzy.common.bean;

public class Result {
	
	private boolean success = true;
	
	private long code = 200;
	
	private String message = "操作成功";
	
	private Object data;
	
	private int totalCount;
	
	public static enum Result_Code {
		err_notLogin(60000, "用户未登录"),
		err_unknown(60001, "未知请求"),
		err_mobilephoneno(60002, "请输入手机号！"),
		err_smsCodeNot(60003, "请输入验证码！"),
		err_smsCodeExpired(60004, "验证码已过期，请重新发送！"),
		err_smsCodeError(60005, "验证码不正确，请重试！"),
		err_unknownLogin(60006, "未知登录类型"),
		err_wechatNotOpenId(60007, "获取微信用户信息失败"),
		err_wechatNotAccessToken(60008, "微信访问无效"),
		err_mobileExist(60009, "该手机号已绑定"),
		err_userMobileBinding(60010, "您已经绑定手机号"),
		err_mobileNotSame(60011, "手机号不一致"),
		err_networkTrafficNotEnough(60012, "可用流量不足"),
		err_shareAlready(60013, "您已经分享过了"),
		err_couponNotExist(60014, "优惠券不存在"),
		err_couponUptAmount(60015, "上架状态不可修改优惠券金额"),
		err_couponUptTime(60016, "上架状态不可修改时间"),
		err_couponUseMin(60017, "上架状态不可修改使用条件"),
		err_couponEndDate(60018, "截止日期必须大于开始日期"),
		err_couponSendDate(60018, "投放日期必须大于当前时间"),
		err_couponAmountZero(60019, "优惠金额不能为零"),
		err_businessSelectNull(60020,"未选择店铺"),
		err_selectNull(60021,"选择为空"),
		err_airportSelectNull(60022,"未选择机场"),
		err_failure(60023,"操作失败"),
		err_bindingPhone(60024,"未绑定手机号"),
		err_bannerNull(60025,"banner不能为空"),
		err_category_not_delete(60026,"该分类下含有商品，不能删除"),
		err_userNotExist(60027,"用户不存在"),
		err_airportNotExist(60028,"没有查询到相关机场"),
		err_smsCodeCountLimit(60029,"验证码发送已达上限"),
		err_couponBusinessNotMatch(60030, "所选店铺与当前店铺不一致"),
		err_couponCountMax(60031, "优惠券金额不能大于优惠券使用条件"),
		err_orderStatus(60031,"订单状态错误"),
		
		
		err_web_smsSendNotMobile(70001, "所选用户无手机号码"),
		err_web_smsSendMessageThirty(70002, "短信内容不得超过三十个字"),
		
		/** 6800 公用 **/
		err_commonDateStr(68000, "时间格式不正确"),
		err_commonStartDate(68001, "开始时间不能为空"),
		err_commonEndDate(68002, "结束时间不能为空"),
		err_commonUpdate(68003, "修改出错"),
		err_commonInsert(68004, "新增出错"),
		err_error(69999, "未知错误");
		private long errorCode;
		private String errorDesc;
		
		public static String getErrorDescribe(long code){
			for (Result_Code result_Code : Result_Code.values()) {
				if (result_Code.getErrorCode() == code) {
					return result_Code.getErrorDesc();
				}
			}
			return "";
		}
		
		private Result_Code(long errorCode, String errorDesc) {
			this.errorCode = errorCode;
			this.errorDesc = errorDesc;
		}
		public long getErrorCode() {
			return errorCode;
		}
		public void setErrorCode(long errorCode) {
			this.errorCode = errorCode;
		}
		public String getErrorDesc() {
			return errorDesc;
		}
		public void setErrorDesc(String errorDesc) {
			this.errorDesc = errorDesc;
		}
	}
	
	public Result() {
		super();
	}
	
	public Result(boolean success) {
		super();
		this.success = success;
	}

	public Result(boolean success, String message) {
		super();
		this.success = success;
		this.message = message;
	}

	public Result(boolean success, String message, Object data) {
		super();
		this.success = success;
		this.message = message;
		this.data = data;
	}
	
	public Result(boolean success, long code, String message, Object data) {
		super();
		this.success = success;
		this.code = code;
		this.message = message;
		this.data = data;
	}
	
	public Result(Result_Code result_Code){
		super();
		this.message = result_Code.getErrorDesc();
		this.success = this.code == result_Code.getErrorCode();
		this.code = result_Code.getErrorCode();
	}
	
	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public long getCode() {
		return code;
	}

	public void setCode(long code) {
		this.code = code;
	}

	public void setCode(long code, boolean auto) {
		this.code = code;
		if (auto) 
			this.message = Result_Code.getErrorDescribe(code);
	}
	
	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}
	
}
